package net.dengzixu.java.homework.period6;

import java.util.Random;

/**
 * @author Deng Zixu <admin@dengzixu.com>
 */
public class Period6Homework2 {
    public static void main(String[] args) {
        int randomNumber = new Random().nextInt(150) + 50;

        System.out.println("生成的随机数为: " + randomNumber);

        switch (randomNumber % 2) {
            case 0:
                System.out.println("这个数是偶数。");
                System.out.println("他的平方为: " + Math.pow(randomNumber, 2));
                break;
            case 1:
                System.out.println("这个数是奇数。");
                System.out.println("他的平方根为: " + (float) Math.sqrt(randomNumber));
                break;
            default:
                System.out.println("不可能走到这里");

        }
    }
}
